#include <unistd.h>
#include <iostream>
#include <sys/types.h>
#include <signal.h>
static void Usage(const std::string &proc)
{
    std::cout << "\nUsage: " << proc << " -signumber process\n" << std::endl;
}

void handler(int signo)
{
    std::cout << "获得一个" << signo << "号信号" << std::endl;
    // exit(1);
}

// ./process -9 12345
int main(int argc, char *argv[])
{
    if(argc != 3)
    {
        Usage(argv[0]);
        exit(0);
    }

    int signumber = std::stoi(argv[1]+1);
    int processpid = std::stoi(argv[2]);
    std::cout << signumber << ' ' << processpid << std::endl;
    kill(processpid, signumber);


    // signal(2, handler);
    // signal(19, handler);
    // signal(20, handler);
    // signal(3, handler);
    // signal(9, handler); // 9号信号，不可被自定义捕捉
    // while(true)
    // {
    //     std::cout << "running...., pid : " << getpid() << std::endl;
    //     sleep(1);
    // }
}
